<?php
//$cur_dt=date("d/m/Y");
//echo $cur_dt;
$file ='downloads_'.$_SESSION['SITE_ID'].'/'.$fname; 

if(ini_get('zlib.output_compression')) 
ini_set('zlib.output_compression', 'Off'); 

//$file_extension = strtolower(substr(strrchr($file,"."),1)); 
$file_extension=substr($file, strrpos($file,".")+1, (strlen($file)-strrpos($file,".")));

if( $file == "" ) 
{ 
echo "<html><head><title>file not found.</title></head><body>file not found.</body></html>"; 
exit; 
} elseif (! file_exists( $file ) ) 
{ 
echo "<html><head><title>The file $file was not found.</title></head><body>The file $file was not found.</body></html>";exit; 
}; 
switch( $file_extension ) 
{ 
case "pdf": $ctype="application/pdf"; break; 
case "zip": $ctype="application/zip"; break; 
case "doc": $ctype="application/msword"; break; 
case "xls": $ctype="application/vnd.ms-excel"; break; 
case "ppt": $ctype="application/vnd.ms-powerpoint"; break; 
case "gif": $ctype="image/gif"; break; 
case "png": $ctype="image/png"; break; 
case "jpeg": 
case "jpg": $ctype="image/jpg"; break; 
case "wav": 
case "mp3": $ctype="application/iTunes"; break; 
default: $ctype="application/force-download"; 
} 
header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: private",false); 
header("Content-Type: $ctype"); 
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" ); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($file)); 
//readfile("$file"); 
exit();
?> 




